]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ScreenShield: Allow lifting up the curtain with the mouse wheel
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 2 Sep 2012 12:48:08 +0000 (14:48 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 3 Sep 2012 15:19:40 +0000 (17:19 +0200)
On a traditional mouse, or with edge-scrolling on a touchpad, it just
feels natural to unlock by scrolling up.

https://bugzilla.gnome.org/show_bug.cgi?id=683164

js/ui/screenShield.js

index ad8ecaed4f2587f3e0931f406658eaf09c42f1be..fd096c9353b4320e0b908c9b526b0da42417f3fc 100644 (file)
@@ -355,6 +355,8 @@ const ScreenShield = new Lang.Class({
                                               });
         this._lockScreenGroup.connect('key-release-event',
                                       Lang.bind(this, this._onLockScreenKeyRelease));
+        this._lockScreenGroup.connect('scroll-event',
+                                      Lang.bind(this, this._onLockScreenScroll));
 
         this._lockScreenContents = new St.Widget({ layout_manager: new Clutter.BinLayout(),
                                                    name: 'lockScreenContents' });
@@ -439,6 +441,27 @@ const ScreenShield = new Lang.Class({
         return true;
     },
 
+    _onLockScreenScroll: function(actor, event) {
+        if (this._lockScreenState != MessageTray.State.SHOWN)
+            return false;
+
+        let delta = 0;
+        if (event.get_scroll_direction() == Clutter.ScrollDirection.UP)
+            delta = 5;
+        else if (event.get_scroll_direction() == Clutter.ScrollDirection.SMOOTH)
+            delta = Math.max(0, event.get_scroll_delta()[0]);
+
+        this._lockScreenScrollCounter += delta;
+
+        // 7 standard scrolls to lift up
+        if (this._lockScreenScrollCounter > 35) {
+            this._ensureUnlockDialog();
+            this._hideLockScreen(0);
+        }
+
+        return true;
+    },
+
     _animateArrows: function() {
         let arrows = this._arrowContainer.get_children();
         let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1);
@@ -656,6 +679,7 @@ const ScreenShield = new Lang.Class({
 
         this._lockScreenState = MessageTray.State.SHOWN;
         this._lockScreenGroup.fixed_position_set = false;
+        this._lockScreenScrollCounter = 0;
 
         this.emit('lock-screen-shown');
     },